import * as path from 'path'
import { defineConfig } from 'vite'
import ViteMonacoPlugin from 'vite-plugin-monaco-editor'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import eslint from 'vite-plugin-eslint'

export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    ViteMonacoPlugin({}),
    eslint({
      cache: false,
      include: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.vue'],
      exclude: ['node_modules'],
    }),
  ],
  build: {
    rollupOptions: {
      external: '@antv/x6-plugin-dnd',
    },
  },
  resolve: {
    alias: [
      {
        find: 'vue',
        replacement: 'vue/dist/vue.esm-bundler.js', // compile template
      },
      {
        find: '@',
        replacement: path.resolve(__dirname, './src'),
      },
      {
        find: '@config',
        replacement: path.resolve(__dirname, './config/index.ts'),
      },
    ],
    extensions: ['.ts', '.js'],
  },
  // server: {
  //   proxy: {
  //     '/api': {
  //       target: 'http://localhost:8080',
  //       changeOrigin: true
  //     }
  //   },
  //   cors: true
  // }
})
